#! /usr/bin/env python
# coding=utf-8

import json
import re
import pandas as pd

import argparse
import sys
from argparse import RawTextHelpFormatter

parser = argparse.ArgumentParser(
    description='''
    将tally得到的 miRNA lane格式 即 序列\t计数
    转化为带计数的fasta格式 

    用法:
    lane2fasta -i out.lane1.unique -o miR1.fa
    ''',formatter_class=RawTextHelpFormatter)



parser.add_argument('-i',
                help='lane文件')

parser.add_argument('-o',
                help='输出的fasta文件')

args = parser.parse_args()

if not args.i or not args.o:
    parser.print_help()
    sys.exit()



infile = args.i

outfile =args.o



outfile = open(outfile,'w')

n = 1
with open(infile) as fila:
	for i in fila:
		k = i.strip().split('\t')
		if len(k)==2:
			
			outfile.write('>'+str(n)+'_x'+str(k[1])+'\n'+k[0]+'\n')
			n += 1
		#break




outfile.close()